// 影院--表现层
var express = require('express');
var router = express.Router();
const { get, create, deleteOne, update } = require("../service/cinemaService");//自行引对应service方法

router.get('/cinemas', async function (req, res, next) {
    const { name, address, phone } = req.query;
    let data = await get({ name, address, phone });
    res.send(data);
});

router.post('/create', async function (req, res, next) {//获取影院信息
    const { name, address, phone, status } = req.body;
    let data = await create({ name, address, phone, status });
    res.send(data);
});
router.delete('/:_id', async function (req, res, next) {//删除
    const { _id } = req.params;
    let data = await deleteOne(_id);
    res.send(data);
});
router.patch('/:_id', async function (req, res, next) {//修改
    const  _id  = req.params;
    const params = req.body;
    let data = await update(_id, params);
    res.send(data);
});

module.exports = router;